Option Strict Off
Option Explicit On

Imports BCS.MotorActivacion.Base

Public NotInheritable Class ErrorsWeb
    Inherits Lista

    Public ReadOnly Property Item() As ErrorWeb
        Get
            Return m_Item
        End Get
    End Property

    Public Sub AddItem(ByVal NewVal As ErrorWeb)
        AddItem(NewVal, True)
    End Sub

    Public Sub AddItem(ByVal NewVal As ErrorWeb, ByVal Refresh As Boolean)
        If Not m_List.Contains(NewVal.Key) Then
            m_List.Add(NewVal)
            If Refresh = True Then
                toRefresh()
            End If
        End If
    End Sub

    Public Sub Add(ByVal Code As Integer, ByVal Desc As String)
        Add(Code, Desc, True)
    End Sub

    Public Sub Add(ByVal Code As Integer, ByVal Desc As String, ByVal Refresh As Boolean)
        Dim ew As ErrorWeb
        ew = New ErrorWeb

        ew.Code = Code
        ew.Description = Desc

        AddItem(ew, Refresh)
    End Sub

    Public Sub Add(ByVal Desc As String)
        Add(Desc, True)
    End Sub

    Public Sub Add(ByVal Desc As String, ByVal Refresh As Boolean)
        Dim ew As ErrorWeb
        ew = New ErrorWeb

        ew.Code = Guid.NewGuid.ToString("D")
        ew.Description = Desc

        AddItem(ew, Refresh)
    End Sub

    Public Overrides Function ToString() As String
        Dim i As Short
        Dim cadena As String
        Dim auxItem As ErrorWeb

        cadena = ""

        For i = 0 To i <= m_List.Count
            auxItem = m_List(i)
            If cadena <> "" Then
                cadena = cadena & "<br>"
            End If
            cadena = cadena & auxItem.ToString
            auxItem = Nothing
        Next

        Return cadena
    End Function
End Class